// 统一管理项目中班级相关的接口
import request from "@/utils/request"

import type { calssAllResponseData, classInfoData, classListFormData, classListResponseData, classResponseData } from "./type"

// 项目班级相关的请求地址
enum API {
    SCHOOL_ALL_URL = "/manage/class/all",
    SCHOOL_LIST_URL = "/manage/class/list",
    SCHOOL_ADD_URL = "/manage/class/add",
    SCHOOL_GET_ID_URL = "/manage/class/find",
    SCHOOL_UPDATE_URL = "/manage/class/update",
    SCHOOL_DELETE_URL = "/manage/class/delete",
}

// 获取所有班级
export const reqClassAll = () =>
    request.get<any, calssAllResponseData>(API.SCHOOL_ALL_URL)

// 获取班级列表
export const reqClassList = (data: classListFormData) =>
    request.post<any, classListResponseData>(API.SCHOOL_LIST_URL, data)

// 添加班级
export const reqClassAdd = (data: classInfoData) =>
    request.post<any, classResponseData>(API.SCHOOL_ADD_URL, data)

// 根据_id查询班级
export const reqClassById = (_id: string) =>
    request.get<any, classResponseData>(API.SCHOOL_GET_ID_URL + `?_id=${_id}`)

// 更新班级信息
export const reqClassUpdate = (data: classInfoData) =>
    request.post<any, classResponseData>(API.SCHOOL_UPDATE_URL, data)

// 删除班级
export const reqClassDelete = (classId: string) =>
    request.post<any, classResponseData>(API.SCHOOL_DELETE_URL, { classId })